function [fig, sortOrder] = plot_nu_CI(nu_draws, EB_nu, highlight_indices, xtick, ytick)

    % Initialization
    N = size(nu_draws, 1);
    nu_post_CI = zeros(N, 3);
    
    % 90% posterior CI for nu-i
    for i = 1:N
        nu_post_CI(i,1) = quantile(nu_draws(i,:), 0.05);  % Lower bound
        nu_post_CI(i,2) = mean(nu_draws(i,:));           % Posterior mean
        nu_post_CI(i,3) = quantile(nu_draws(i,:), 0.95);  % Upper bound
    end
    
    % Sort intervals based on ascending lower bounds
    [~, sortOrder] = sortrows(nu_post_CI(:,1));
    nu_post_CI = nu_post_CI(sortOrder,:);
    
    fig = figure;
    set(fig, 'Units', 'inches', 'Position', [1 1 5.833 4.373]); 
    hold on;
    
    for i = 1:N
        % Determine color based on whether it's a highlighted index
        if ismember(i, highlight_indices)
            lineColor = [0.2, 0.6, 0.9]; % Light blue for highlighted indices   
        else
            lineColor = [0.8, 0.3, 0.3]; % Pink for regular indices
        end
        
        % Plot vertical line connecting upper and lower bound
        plot([i, i], [nu_post_CI(i,1), nu_post_CI(i,3)], 'Color', lineColor, 'LineWidth', 1);
        
        % Plot horizontal dashed lines at upper and lower bounds
        plot([i-0.4, i+0.4], [nu_post_CI(i,3), nu_post_CI(i,3)], 'Color', lineColor, 'LineWidth', 1);
        plot([i-0.4, i+0.4], [nu_post_CI(i,1), nu_post_CI(i,1)], 'Color', lineColor, 'LineWidth', 1);
        
        % Plot dot for posterior mean (same color as lines)
        plot(i, nu_post_CI(i,2), 'o', 'MarkerSize', 3, 'MarkerFaceColor', lineColor, 'MarkerEdgeColor', lineColor);
    end

    % Add reference line at EB estimate
    yline(EB_nu, 'k--', 'LineWidth', 1);
    
    % Set axis limits and ticks
    yticks(ytick);
    ylim([ytick(1), ytick(end)]);
    xticks(xtick);
    xlim([xtick(1), xtick(end)]);
    set(gca, 'FontSize', 18);
    
    hold off;

end